# -*- encoding:utf-8 -*-
# @time: 2023/3/20 22:59
# @author: Maxs_hu
from django import forms
from django.forms import widgets
from web import models


class LevelModelForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        for name, field in self.fields.items():
            field.widget.attrs['class'] = 'form-control'

    class Meta:
        model = models.Level  # 关联表
        fields = ['title', 'percent']
        widgets = {
            'title': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入标题'}),
            'percent': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入折扣'}),
        }



